import Schemas from '../schemas';
import { Mongo } from 'meteor/mongo';

const ChannelTypes = new Mongo.Collection('channelTypes');

ChannelTypes.attachSchema(Schemas.ChannelType);

if (Meteor.isServer) {
  Meteor.publish('Get.ChannelTypes', function() {
    return ChannelTypes.find({});
  });
}

const getChannelTypes = () => {
  if (Meteor.isClient) {
    Meteor.subscribe('Get.ChannelTypes');
  }

  return ChannelTypes.find({});
};

export { ChannelTypes, getChannelTypes };